#ifndef _NEURON_
#define _NEURON_

#include <vector>
#include <string>
#include <stdio.h>
#include <assert.h>
#include <myMacros.h>

using namespace std;

class neuron {
  private:
    double calcSum (dVec_t inputs) {
      assert (inputs.size() == weights.size());

      double sum = bias;
      forEach (i, 0, weights.size())
        sum += weights[i] * inputs[i];

      return sum;
    }

    virtual double activation (double sum)=0;

  public:
    double bias;
    dVec_t weights;

    void show () {
      printf ("(%+.6f)", bias);
      forEach (i, 0, weights.size())
        printf ("|%+.6f", weights[i]);
    }

    neuron (double ibias, dVec_t iWeights) : bias(ibias), weights(iWeights) {}

    double getOutput (dVec_t inputs) {
      assert (inputs.size() == weights.size());
      return activation (calcSum (inputs));
    }

    bool addInput (double initialWeight = 0) {
      weights.push_back(initialWeight);
      return true;
    }
};

typedef vector<neuron*>  layer_t;
typedef vector<layer_t>  net_t;

#endif
